var divide = function(dividend, divisor) {
    let div1 = dividend
    let div2 = divisor
    let Max = Math.pow(2,31) - 1
    let Min = - Math.pow(2,31)
    let res = 0

    if(div1 == Min &&　div2 == -1){
        return Max
    }
    if(div1 == Min){
        div1 = 2147483648
    }else{
        div1 = Math.abs(div1)
    }
    div2 = Math.abs(div2)


    for(let i = 31;i >= 0;i--){
        if((div1 >> i) >= div2){
            res += 1 << i
            div1 -= div2 << i
        }
    }
    let flag = (dividend ^ divisor) >= 0 ? true:false
    return flag ? res : -res
};

let a = -2147483648,b = 1;
console.log(divide(a,b))
